﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SewerAPI.Security;
using SewerAPI.Core;

namespace SewerAPITest
{
    [TestClass]
    public class SecurityTest
    {
        public static Message GetTestMessage()
        {
            Message _m = new PublicMessage("blabla");
            _m.Channel = "AnyChannel";
            _m.From = "AnyFrom";
            return _m;
        }

        public byte[] InflateByteArray(byte[] array)
        {
            byte[] newarray = new byte[array.Length+50];
            array.CopyTo(newarray,0);
            return newarray;
        }
        
        [TestMethod]
        public void EncryptAndDecryptChannel()
        {
            StandardEncryptionEngine _e = new StandardEncryptionEngine();
            string expected = GetTestMessage().Channel;
            byte[] encrypted = _e.EncryptChannel(GetTestMessage());
            string actual = _e.DecryptChannel(InflateByteArray(encrypted));
            Assert.AreEqual(expected, actual);
        }
    }
}
